package client;

import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import java.util.ArrayList;

/**
 *
 * @author Ben
 * Purpose: simple animation system
 */
public class AnimationHelper 
{
    public static class BaseAnimation extends AnimationHelper
    {
        float speed;
        float time;
        Spatial grab;
        boolean repeat;
        boolean internal;
        static ArrayList<AnimThread> threads = new ArrayList();
        static ArrayList<ItemAnimation> id_ia = new ArrayList();
        
        static public void doThread()
        {
            for(int i = 0; i < threads.size(); i++)
            {
                AnimThread temp = threads.get(i);
                ItemAnimation tempa = id_ia.get(temp.animIn);
                Spatial tempn = temp.grab;
            }
        }

    }
    
    public static class ItemAnimation extends BaseAnimation
    {
        static public void registerAnimsItems()
        {
            ItemAnimation spinA = null;
            ItemAnimation bounceA = null;
            id_ia.add(0,spinA);
            id_ia.add(1,bounceA);
        }
        
        public static class spinA extends ItemAnimation
        {
            float speeda;
            float timea;
            Spatial graba;
            
            public spinA(float speed, float time, Spatial grab)
            {
                speeda = speed;
                timea = time;
                graba = grab;
                do_a();
            }
            
            public void do_a()
            {
                graba.rotate(new Quaternion((float) Math.PI * speeda, 0, 0, 0).fromAngleAxis(30f, graba.getWorldTranslation().normalizeLocal()));
            }
        }
        
        public static class bounceA extends ItemAnimation
        {
            public bounceA(float speed, float time, Spatial grab)
            {
                for (int i = 0; i < time * 5; i++)
                {
                    int oldy = (int) grab.getWorldTranslation().y;
                    grab.move(0, oldy + 1, 0);
                }
                for (int d = 0; d < time * 5; d++)
                {
                    int oldy = (int) grab.getWorldTranslation().y;
                    grab.move(0, oldy - 1, 0);
                }
            }
        }
    }
    
    public static class AnimThread extends BaseAnimation
    {
        Spatial itemIn;
        int animIn;
        
        public AnimThread(Spatial item, int anim)
        {
            itemIn = item;
            animIn = anim;
        }
        
        public AnimThread toThread (Spatial item, int anim)
        {
            return new AnimThread(item,anim);
        }
        
        public void addThread(Spatial item,int anim)
        {
            threads.add(toThread(item,anim));
        }
    }
}
